package com.zmn.plat.common.dictionary;

/**
 * 保修规则枚举
 *
 * @author linfeng
 * @since 2020/06/08 14:56:30
 */
public enum WarrantyRuleEnum {

    /**
     * values
     */
    NOWARRANTY(1, "不保修"),
    MACHINEWARRANTY(2, "整机保修"),
    SAMELOCATIONWARRANTY(3, "同性质且同部位故障"),
    INSTALLATIONFAILURES(4, "安装引起的故障"),
    CLEANINGFAILURES(5, "清洗引起的故障"),
    SAMENATUREFAULT(6, "同性质故障")
    ;

    private Integer code;
    private String name;

    WarrantyRuleEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static WarrantyRuleEnum of(Integer code) {
        if (code == null || code == 0) {
            return NOWARRANTY;
        }
        switch (code) {
            case 1:
                return NOWARRANTY;
            case 2:
                return MACHINEWARRANTY;
            case 3:
                return SAMELOCATIONWARRANTY;
            case 4:
                return INSTALLATIONFAILURES;
            case 5:
                return CLEANINGFAILURES;
            case 6:
                return SAMENATUREFAULT;
            default:
                return NOWARRANTY;
        }
    }
}
